﻿using CompanyManageSystem.Model;
using CompanyManageSystem.Service;
using DevExpress.XtraGrid.Columns;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CompanyManageSystem.UI.Info
{
    public partial class Other : Form
    {
        //当前的页码
        private int NowPageNumber = 1;

        public Other()
        {
            InitializeComponent();
        }

        private void Other_Load(object sender, EventArgs e)
        {
            //AppService aservice = new AppService();
            //gridControl1.DataSource = aservice.GetCompanyStaffInfo();
        }

        private void page1_Load(object sender, EventArgs e)
        {
            var pservice = new AppService();
            int number = pservice.GetCompanyStaffInfo().Count();
            page1.PageSize = 3;
            if (number % page1.PageSize != 0)
            {
                page1.PageCount = number / page1.PageSize + 1;
            }
            else
            {
                page1.PageCount = number / page1.PageSize;
            }
            page1.PageIndex = 1;
            page1.TotalCount = number;
            PageTurning();
        }

        private void page1_DataRefresh(object sender, EventArgs e)
        {
            var pservice = new AppService();
            page1.TotalCount = pservice.GetCompanyStaffInfo().Count();
            if (page1.TotalCount % page1.PageSize != 0)
            {
                page1.PageCount = page1.TotalCount / page1.PageSize + 1;
            }
            else
            {
                page1.PageCount = page1.TotalCount / page1.PageSize;
            }

            PageTurning();
        }

        private void PageTurning()
        {
            this.NowPageNumber = page1.PageIndex;
            var pservice = new AppService();
            //跳转几条数据再开始获取
            int num = (page1.PageIndex - 1) * page1.PageSize;
            gridControl1.DataSource = pservice.GetStallInPage(num, page1.PageSize);

        }

    }
}
